<!-- <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="text">
      <button id="send">发送</button>
<script>
     let websocket = new WebSocket('ws://127.0.0.1:8080/test');
     
     websocket.onopen = function(){
        console.log("连接成功");
     };
     websocket.onmessage = function(e){
        console.log("收到信息"+e.data);
        alert("服务器返回:"+e.data);
     };
     websocket.onerror = function(){
        console.log("连接发生异常");
     };
     websocket.onclose = function(){
        console.log("连接关闭");
     };
     
     let but = document.querySelector("#send") ; 
     let me = document.querySelector('#text') ; 
     but.onclick = function(){
        console.log("发送信息");
        websocket.send(me.value) ; 
     }


</script>
</body>
</html> -->